home *** CD-ROM | disk | FTP | other *** search
- on doUniqList indexID, byNameField, outputList
- global stateDB, restDB, fullstateDEX, stateDEX, cuisineDEX, specialtyDEX, abbrevstateDEX
- set DBResult to DBSelect(restDB)
- checkFail(DBResult, "Error selecting restaurant data file.")
- set DBResult to DBSelectIndex(indexID)
- checkFail(DBResult, "Error selecting index file.")
- set DBResult to DBTop()
- checkFail(DBResult, "Error moving to top of database.")
- set lastFound to EMPTY
- set resultList to EMPTY
- repeat while 1 = 1
- set theName to DBGetFieldByName(byNameField)
- if indexID = stateDEX then
- set DBResult to DBSelect(stateDB)
- checkFail(DBResult, "Error selecting state data file.")
- set DBResult to DBSelectIndex(fullstateDEX)
- checkFail(DBResult, "Error selecting full state index file.")
- set theExpr to DBBuildSeekExpr(abbrevstateDEX, theName)
- set DBResult to DBSeek(theExpr)
- if DBResult = 3 then
- set theName to "<unknown state>"
- else
- set theName to DBGetFieldByName("FULLNAME")
- end if
- set DBResult to DBSelect(restDB)
- checkFail(DBResult, "Error selecting restaurant data file.")
- set DBResult to DBSelectIndex(indexID)
- checkFail(DBResult, "Error selecting index file.")
- end if
- if theName <> lastFound then
- if resultList <> EMPTY then
- put RETURN after resultList
- end if
- set lastFound to theName
- put theName after resultList
- end if
- set DBResult to DBSkip(1)
- if DBResult = 3 then
- put resultList into field outputList
- exit
- end if
- end repeat
- end
-
- on resetQuery
- global byCuisineVal, bySpecialtyVal, byStateVal
- set byCuisineVal to EMPTY
- set bySpecialtyVal to EMPTY
- set byStateVal to EMPTY
- put EMPTY into field "specialtyList"
- put EMPTY into field "cuisineList"
- put EMPTY into field "stateList"
- put EMPTY into field "query expression"
- put EMPTY into field "info"
- put EMPTY into field "matchList"
- set the hilite of member "by specialty" to 0
- set the hilite of member "by cuisine" to 0
- set the hilite of member "by state" to 0
- set the hilite of member "reservations accepted" to 0
- set the hilite of member "valet parking available" to 0
- set the hilite of member "credit cards accepted" to 0
- set the hilite of member "handicap access available" to 0
- set the hilite of member "find by criteria" to 0
- set the hilite of member "find all" to 1
- set the loc of sprite 24 to point(21, 113)
- updateStage()
- end
-
- on buildQueryExpr
- global byStateVal, bySpecialtyVal, byCuisineVal, restDB, stateDB, abbrevstateDEX
- set singleQuote to "'"
- set theExpr to EMPTY
- if byStateVal <> EMPTY then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- set DBResult to DBSelect(stateDB)
- checkFail(DBResult, "Error selecting state data file.")
- set DBResult to DBSelectIndex(fullstateDEX)
- checkFail(DBResult, "Error selecting state abbreviation index.")
- set seekExpr to DBBuildSeekExpr(fullstateDEX, byStateVal)
- set DBResult to DBSeek(seekExpr)
- set abbrevstate to DBGetFieldByName("ABBREV")
- put "STATE = " & singleQuote & abbrevstate & singleQuote after theExpr
- set DBResult to DBSelect(restDB)
- checkFail(DBResult, "Error selecting restaurant data file.")
- end if
- if byCuisineVal <> EMPTY then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- put "CUISINE = " & singleQuote & byCuisineVal & singleQuote after theExpr
- end if
- if bySpecialtyVal <> EMPTY then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- put "SPECIALITY = " & singleQuote & bySpecialtyVal & singleQuote after theExpr
- end if
- if the hilite of member "Reservations accepted" = 1 then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- put "RESERVE = .T." after theExpr
- end if
- if the hilite of member "Credit cards accepted" = 1 then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- put "CREDITCARD = .T." after theExpr
- end if
- if the hilite of member "Valet parking available" = 1 then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- put "VALET = .T." after theExpr
- end if
- if the hilite of member "Handicap access available" = 1 then
- if theExpr <> EMPTY then
- put " .AND. " after theExpr
- end if
- put "ACCESS = .T." after theExpr
- end if
- put theExpr into field "query expression"
- end
-